const isAnagram = (s, t) => {
    if (s.length !== t.length) {
        return false;
    }
    const hash = {};
    for (const k of s) {
        hash[k] = hash[k] || 0;
        hash[k] += 1;
    }
    for (const k of t) {
        if (!hash[k]) {
            return false;
        }
        hash[k] -= 1;
    }
    return true;
};

var a = isAnagram(s = "anagram", t = "nagaram")
console.log(a);
